<template>
	<view class="recommendMaster">
		<u-navbar title="品鉴推介师" :border-bottom="false"></u-navbar>
		<!-- <view class="header">
			<img src="../../static/wj.png" alt="" class="img" />
			数据汇总（扣除无效订单）：￥2,000.251
		</view> -->
		<scroll-view class="msg" scroll-y="true" @scrolltolower="lower">
			<view v-for="(item, index) in flowList" :key="index" class="items">
				<view class="t">
					<view class="l">
						<img class="t_img" :src="item.avatar" alt="" />
						<view class="warp">
							<view class="name">{{ item.username }}</view>
							<view class="tel">电话：{{ item.tel }}</view>
						</view>
					</view>
					<view v-if="item.is_check === 1">
						<view>已分佣{{ item.count_info.fy_money }}元</view>
						<view class="tel">{{ item.count_info.t_nums }}个订单</view>
					</view>
					<view class="r" v-else>
						<view class="bt" @click="isCheck1(item.ouid)">审核通过</view>
					</view>
				</view>
				<view class="b">
					<view class="l">{{ item.is_check === 1 ? '入驻时间' : '申请时间' }}：{{ item.create_time }}</view>
					<view class="r bt" v-if="item.is_check === 1" @click="extensionOrder(item.ouid)">查看推广订单</view>
					<view class="r bt" v-else @click="isCheck2(item.ouid)">审核拒绝</view>
				</view>
			</view>

			<view style="padding: 20rpx 0rpx; box-sizing: border-box">
				<u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" :bg-color="'none'"></u-loadmore>
			</view>
		</scroll-view>
	</view>
</template>

<script>
import { pjsList, checkPjs } from '../../libs/axios.js';
export default {
	data() {
		return {
			status: true,
			loadStatus: 'loadmore',
			page_num: 1,
			flowList: []
		};
	},
	onLoad() {
		this.lower();
	},
	methods: {
		extensionOrder(id) {
			uni.navigateTo({
				url: '/pages/extensionOrder/extensionOrder?id=' + id
			});
		},
		isCheck1(id) {
			const _this = this;
			uni.showModal({
				title: '提示',
				content: '请问是否通过',
				async success(res) {
					if (res.confirm) {
						let info = await checkPjs({
							ouid: id,
							is_check: 1
						});
						uni.showToast({
							title: info.message,
							icon: 'success',
							duration: 2000
						});
						_this.loadStatus = 'loadmore';
						_this.page_num = 1;
						_this.flowList = [];
						_this.lower();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		isCheck2(id) {
			const _this = this;
			uni.showModal({
				title: '提示',
				content: '请问是否拒绝',
				async success(res) {
					if (res.confirm) {
						let info = await checkPjs({
							ouid: id,
							is_check: 2
						});
						uni.showToast({
							title: info.message,
							icon: 'success',
							duration: 2000
						});
						_this.loadStatus = 'loadmore';
						_this.page_num = 1;
						_this.flowList = [];
						_this.lower();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		async lower() {
			if (this.loadStatus === 'nomore') {
				return false;
			} else {
				this.loadStatus = 'loading';
			}
			let option = {
				pageIndex: this.page_num,
				pageSize: 10
			};
			let info = await pjsList(option);
			this.Partotal = info.data.meta.total;
			info.data.list.forEach((item) => {
				item.avatar = this.$store.state.imgUrl + item.avatar;
				item.create_time = this.$moment(item.create_time * 1000).format('YYYY-MM-DD hh:mm:ss');
				this.flowList.push(item);
			});
			if (info.data.list.length === 10) {
				this.page_num += 1;
				this.loadStatus = 'loadmore';
			} else {
				this.loadStatus = 'nomore';
			}
		}
	}
};
</script>

<style lang="scss">
.recommendMaster {
	height: 100vh;
	background: rgba(245, 245, 245, 1);
	padding-bottom: constant(safe-area-inset-bottom); /*兼容 IOS<11.2*/
	padding-bottom: env(safe-area-inset-bottom); /*兼容 IOS>11.2*/
	.header {
		display: flex;
		align-items: center;
		padding: 30rpx;
		background: #fff;
		.img {
			width: 23.8rpx;
			height: 28.5rpx;
			margin-right: 20rpx;
		}
	}
	.msg {
		margin-top: 30rpx;
		height: 75vh;
		overflow: scroll;
		.items {
			width: 690rpx;
			opacity: 1;
			border-radius: 20rpx;
			background: rgba(255, 255, 255, 1);
			margin: 20rpx auto;
			padding: 32rpx 28rpx;
		}
		.t {
			display: flex;
			justify-content: space-between;
			margin-left: 14rpx;
			font-size: 26rpx;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			.l {
				display: flex;
				align-items: center;
				.t_img {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
				}
				.warp {
					margin-left: 14rpx;
					.name {
					}
				}
			}
			.tel {
				margin-top: 14rpx;
			}
			.r {
				display: flex;
				align-items: center;
			}
		}
		.b {
			display: flex;
			justify-content: space-between;
			align-items: flex-end;
			margin-top: 14rpx;
			.l {
				font-size: 24rpx;
				font-weight: 400;
				color: rgba(153, 153, 153, 1);
			}
			.r {
			}
		}
		.bt {
			padding: 6rpx 14rpx;
			border-radius: 24rpx;
			border: 1rpx solid rgba(193, 193, 193, 1);
			font-size: 24rpx;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
}
</style>